﻿using System;
using NGuestBook.IDAL;

namespace NGuestBook.Factory
{
    /**//// <summary>
    /// 数据访问层工厂，用于获取相应的数据访问层对象
    /// 使用Abstract Factory设计模式+Facace设计模式+反射机制+缓存机制设计
    /// </summary>
    public sealed class DALFactory
    {
        /**//// <summary>
        /// 获取管理员数据访问层对象
        /// </summary>
        /// <returns>管理员数据访问层对象</returns>
        public static IAdminDAL CreateAdminDAL()
        {
            return (IAdminDAL)DependencyInjector.GetDALObject("AdminDAL");
        }

        /**//// <summary>
        /// 获取留言数据访问层对象
        /// </summary>
        /// <returns>留言数据访问层对象</returns>
        public static IMessageDAL CreateMessageDAL()
        {
            return (IMessageDAL)DependencyInjector.GetDALObject("MessageDAL");
        }

        /**//// <summary>
        /// 获取评论数据访问层对象
        /// </summary>
        /// <returns>评论数据访问层对象</returns>
        public static ICommentDAL CreateCommentDAL()
        {
            return (ICommentDAL)DependencyInjector.GetDALObject("CommentDAL");
        }
    }
}